<?php if(!isset($cosa) && !$cosa->system('installed')) die(); ?>
<div class="install">
	<div id="header">
		<div id="navigation">
			<h1><span>COSA</span></h1>
		</div>
		<div id="breadcrumb">
			<h2>Welcome. Thank you for choosing COSA!</h2>
		</div>
	</div>
	<div id="main">
		<h2>Settings</h2>
		<p>
			Great! You have set up the config file correctly.<br />
			Submit the form below to continue your installation.
		</p>
		<br />
		<form method="post" action="<?php echo $cosa->system('base-url'); ?>/" onsubmit="return validate(this);" class="clearfix">
		<input type="hidden" name="install" value="1" />
		<ul>
			<li class="clearfix" style="padding: 0;">
				<ul class="clearfix">
					<li class="fl-l" style="padding: 20px;">
						<ul>
							<li><label for="site_title">Site title <abbr title="Required field">*</abbr></label>
								<input type="text" name="site_title" id="site_title" value="" class="fld" />
							</li>
							<li><label for="base_url">URL to COSA <abbr title="Required field">*</abbr></label>
								<input type="text" name="base_url" id="base_url" value="<?php echo $cosa->system('base-url'); ?>" class="fld" />
							</li>
							<li><label for="site_url">URL to the site <abbr title="Required field">*</abbr></label>
								<?php
								$site_url = str_replace('http://', '', $cosa->system('base-url'));
								$site_url = explode('/', $site_url);
								array_pop($site_url);
								$site_url = 'http://'.implode('/', $site_url);
								?><input type="text" name="site_url" id="site_url" value="<?php echo $site_url; ?>" class="fld" />
							</li>
							<li><label for="charset">Character set <abbr title="Required field. Set to 'utf-8' if you don't know.">*</abbr></label>
								<input type="text" name="charset" id="charset" value="utf-8" class="fld" />
							</li>
						</ul>
					</li>
					<li class="fl-l" style="border-left: 10px solid #fff; padding: 20px; margin: 0;">
						<ul>
							<li><label for="uname">Username <abbr title="Required field">*</abbr></label>
								<input type="text" name="uname" id="uname" value="admin" class="fld" />
							</li>
							<li><label for="pass">Password <abbr title="Required field">*</abbr></label>
								<input type="password" name="pass" id="pass" value="" class="fld" />
							</li>
							<li><label for="name_f">First name</label>
								<input type="text" name="name_f" id="name_f" value="" class="fld" />
							</li>
							<li><label for="name_l">Name</label>
								<input type="text" name="name_l" id="name_l" value="" class="fld" />
							</li>
							<li><label for="email">Email</label>
								<input type="text" name="email" id="email" value="" class="fld" />
							</li>
						</ul>
					</li>
				</ul>
			</li>
			<li id="error" style="display:none;">
				Please enter all required fields.
			</li>
			<li><input type="submit" value="Submit" /></li>
		</ul>
		</form>
		<script type="text/javascript">
		function validate(f) {
			if(!validateFieldEmpty('site_title')) return false;
			if(!validateFieldEmpty('base_url')) return false;
			if(!validateFieldEmpty('site_url')) return false;
			if(!validateFieldEmpty('charset')) return false;
			if(!validateFieldEmpty('uname')) return false;
			if(!validateFieldEmpty('pass')) return false;
			return true;
		}
		function validateFieldEmpty(id) {
			if(!$('#'+id)) return false;
			var el = $('#'+id);
			if(el.attr('value') == '') {
				el.addClass('error');
				$('#error').show();
				return false;
			} else {
				el.removeClass('error');
				$('#error').hide();
				return true;
			}
		}
		</script>
	</div>
</div>